import json
import yaml

SEP = '.'

crawler_cfg = None
with open("../conf/crawler.json", "r") as open_file:
    crawler_cfg = json.load(open_file)

core_cfg = None
with open("../conf/crawler_core.yaml", "r") as open_file:
    core_cfg = yaml.full_load(open_file)


def get_core_cfg(key):
    split_keys = key.split(SEP)
    cur_elem = core_cfg
    for split_key in split_keys:
        if '__contains__' in dir(cur_elem) and cur_elem.__contains__(split_key):
            cur_elem = cur_elem[split_key]
        else:
            return None
    return cur_elem
